
Genetic Algorithm
Search Algorithms: Object-Oriented Implementation (Part A) 23
function GENETIC-ALGORITHM(population, FITNESS-FN) returns an individual
inputs: population, a set of individuals
FITNESS-FN, a function that measures the fitness of an individual
repeat
new_population ¬ empty set
for i = 1 to SIZE(population) do
(x, y) ¬ SELECT-PARENTS(population, FITNESS-FN)
child ¬ REPRODUCE(x, y)
if (small random probability) then child ¬ MUTATE(child)
add child to new_population
population ¬ new_population
until some individual is fit enough, or enough time has elapsed
return the best individual in population, according to FITNESS-FN